package com.hourese.listener;

import com.hourese.util.sendDX;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@RabbitListener(queues = "sms")
public class SmsListener {
    @Autowired
    private sendDX sendDX;
    @RabbitHandler
    public void executeSms(Map<String,String>map){
        String phone= map.get("mobile");
        String code=map.get("random");
        System.out.println("手机号:"+map.get("mobile"));
        System.out.println("验证码:"+map.get("random"));
        try {
            sendDX.send(phone,code);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
